//导入工具包
var gulp = require('gulp'),
    less = require('gulp-less'),
    rename = require('gulp-rename'),
    cleanCSS = require('gulp-clean-css'),
    autoprefixer = require('gulp-autoprefixer'),
    fontSpider = require( 'gulp-font-spider' );
    // babel = require('gulp-babel');


// 编译less 压缩less
gulp.task('reduceLess', function () {
    return gulp.src('src/less/main.less')
        .pipe(less())
        .pipe(cleanCSS())
        .pipe(autoprefixer({
            browsers: ['last 2 version', 'safari 5', 'ie 8', 'ie 9', 'opera 12.1', 'ios 6', 'android 4'],
            cascade: true, //是否美化属性值
            remove:true //是否去掉不必要的前缀 默认：true
        }))
        // .pipe(rename('main.min.css'))
        .pipe(gulp.dest('dist/css'));
});

gulp.task('fontspider', function() {
  return gulp.src('page/font.html')
    .pipe(fontSpider());
});

// es6转换es5
// gulp.task('changeJs', function () {
//   return gulp.src('src/js/*.js')
//     .pipe(babel())
//     .pipe(gulp.dest('dist/js'));
// });

// 实时编译less
gulp.task('watch', function() {
    gulp.watch(['src/less/*.less'],['reduceLess']);
    // gulp.watch(['src/js/*.js'],['changeJs']);
});